﻿<%@ WebHandler Language="C#" Class="ListHTMLhandler" %>

using System.Data;
using System.Web;




public class ListHTMLhandler : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string t = context.Request.Params["table"].ToString();
        string sql = context.Request.Params["sql"].ToString();
        DB excute = new DB(); 
        DataSet dts =new DataSet ();
        if (excute.Execte(sql))
        {
             dts=excute.Get("select classname,time from " + t +" order by time ASC" , t);
                foreach (DataTable tb in dts.Tables)
                {
                    switch (tb.TableName)
                    {
                        case "newsclass":
                            using (StaticBase sb = new ListPage(tb, FlagsFileName.Newsclass))
                            {
                                if (!sb.Osucess)
                                {
                                    System.Web.HttpContext.Current.Response.Write("<script language=javascript>alert('" + sb.Errorstring + "')</script>");
                                }
                            }
                            break;
                        case "productclass":
                            using (StaticBase sb = new ListPage(tb, FlagsFileName.Productclass))
                            {
                                if (!sb.Osucess)
                                {
                                    System.Web.HttpContext.Current.Response.Write("<script language=javascript>alert('" + sb.Errorstring + "')</script>");
                                }
                            }
                            break;
                        case "navigation":
                            using (StaticBase sb = new ListPage(tb, FlagsFileName.Navigation,tb.TableName.ToString()))
                            {
                                if (!sb.Osucess)
                                {
                                    System.Web.HttpContext.Current.Response.Write("<script language=javascript>alert('" + sb.Errorstring + "')</script>");
                                }
                            }
                            break;
                        default: break;
                    }
                }
            dts.Clear();
            dts.Tables.Clear();
            context.Response.Write("成功");
            context.Response.End();
        }
        else { context.Response.Write("失败"); context.Response.End();}
       
       
        
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}